jQuery(document).ready(function ($) {
    $('form[name="Inquiry"]').on('submit', function (e) {
        e.preventDefault();

        var form = $(this);
        var formData = form.serialize();
        var nonce = form.find('input[name="nonce"]').val();
        
        //client side validation 
        

        $.ajax({
            method: 'POST',
            url: handle.site_url + '/wp-json/message-form/v1/submit',
            data: formData,
             beforeSend: function (xhr) {
                xhr.setRequestHeader('X-WP-Nonce', handle.nonce); // Include nonce in the request header
            },
            success: function (response) {
                // Handle success response
                form[0].reset();
                console.log(response);
            },
            error: function (xhr, status, error) {
                // Handle error response
                console.error(error);
            }
        });
    });
});